/*
 * 作者:熊猫
 * 日期:2017 - 3 - 17 10 - 25 - 34
 *
 */

package net.lainiao.morethread.Chapter7.demo5;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/17.
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        MyScheduledThreadPoolExectutor exectutor=new MyScheduledThreadPoolExectutor(2);
        Task task=new Task();
        System.out.println("Main:"+new Date());
        exectutor.schedule(task,1, TimeUnit.SECONDS);
        TimeUnit.SECONDS.sleep(3);
        task=new Task();
        System.out.println("Main : "+new Date());
        exectutor.scheduleAtFixedRate(task,1,2,TimeUnit.SECONDS);
        TimeUnit.SECONDS.sleep(10);
        exectutor.shutdown();
        exectutor.awaitTermination(1,TimeUnit.DAYS);
        System.out.println("Main Over");
    }
}
